from speech.baidu.speech_recognition import *
from audio.audio_filter import *
from .params_config import BAIDU_ACCESS_TOKEN

_SONIC_CONF = {
    'channels': 1,
    'sample_width': 2,
    'sample_frequency': 16000,
    'sample_length': 2048
}
_SONIC_CONF = Sonic(**_SONIC_CONF)


_BANDPASS_FILTER = butter_bandpass(150, 2000, _SONIC_CONF.sample_frequency)
_RECORD_CONF = {
    'gate_value': 700,
    'series_min_count': 30,
    'block_min_count': 8,
    'speech_filter': _BANDPASS_FILTER
}
_RECORD_CONF = RecordConf(**_RECORD_CONF)


SPEECH_RECOGNIZER = BaiduSpeechRecognizer(BAIDU_ACCESS_TOKEN, _SONIC_CONF, _RECORD_CONF)
if not SPEECH_RECOGNIZER:
    raise Exception("Can`t instantiate BaiduSpeechRecognizer")

